﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace VXCompany.SilverlightLogging.Services.Exceptions.LoggingSinks
{
	/// <summary>
	/// Fallback scenario Exception sink. 
	/// Will not persist any errors across sessions. 
	/// Do not use in a production scenario.
	/// </summary>
	public class SessionSink : ILoggingSink
	{
		private const string SESSION_KEY = "SilverlightLogging";

		/// <summary>
		/// Handles Exception. Stores it in session. Do not use in a production scenario.
		/// </summary>
		/// <param name="ex"></param>
		/// <returns></returns>
		public bool Log(Exception ex)
		{
			bool success = false;
			if (System.Web.HttpContext.Current != null)
			{
				System.Web.HttpContext.Current.Session[SESSION_KEY] = ex;
				success = true;
			}
			return success;
		}
	}
}